import api from "../../api";


const state = {
	userInfo: {
		name: '张三',
		age: '18',
		text: '啦啦啦，123，是是是。',
	},
}
const mutations = {

	// 获取用户信息
	SET_USER_DATA(state, params) {
		state.userInfo = params
	},

	// 清除用户信息
	CLEAR_USER_DATA(state) {
		console.log('重置Data')
		state.userInfo = {}
	},
}
const actions = {

	async getUserInfo({
		commit
	}, uid) {
		const res = await api.user.getUserInfo(uid)
		commit('SET_USER_DATA', res)
	},

	clearUserData({
		commit
	}) {
		commit('CLEAR_USER_DATA')
	}

}


export default {
	namespaced: true,
	state,
	mutations,
	actions
}
